#include <stdio.h>

#include "LinkedList.c"

void makeNode1();
void makeList1();
void makeList2();

int main() {
	printf("============================================================ Linked list main test\n");

	makeNode1();
	makeList1();
	makeList2();

	printf("\n");
	return 0;
}

/** make 1 node, dump, set, and free **/
void makeNode1() {
	printf("\n---------------------------------------------------------- Make node routine\n\n");
	LNode *node = newNode(10);
	
	dumpNode(node);
	setNodeData(node, 11);
	dumpNode(node);

	deleteNode(node);
}

/** make a list with one element, dump, add element, dump, remove element and dump  **/
void makeList1() {
	printf("\n---------------------------------------------------------- Make list routine\n");
	LNode *node1 = newNode(11);
	LNode *node2 = newNode(20);
	List *l = newList(node1);
	dumpHeadTail(l);
	
	printf("add one node in head");
	addInHead(l, node2);
	dumpHeadTail(l);

	printf("remove tail");
	removeTail(l);
	dumpHeadTail(l);

	deleteNode(node2);
	deleteList(l);
}

/** make a list with few elements, dump with iterator **/
void makeList2() {
	printf("---------------------------------------------------------- Make list routine with iterator\n");
	LNode *node1 = newNode(11);
	LNode *node2 = newNode(20);
	LNode *node3 = newNode(24);
	LNode *node4 = newNode(42);
	List *l = newList(node1);
	LIterator *itr = newIterator(l);

	printf("\nadd nodes");
	addInHead(l, node2); addInHead(l, node3); addInHead(l, node4);
	dumpTraverse(itr);

	deleteLIterator(itr);
	deleteList(l);

}
